package de.haw.gka.a1;


import org.jgrapht.WeightedGraph;
import org.jgrapht.graph.AbstractGraph;
import org.jgrapht.graph.DefaultEdge;
import org.jgrapht.graph.DefaultWeightedEdge;
import org.jgrapht.graph.WeightedPseudograph;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;

import static org.junit.Assert.assertEquals;





public class TestAlgo {
	

	
	private AlgoHierholzer hier;
	private AlgoFleury fleury;
	 AbstractGraph<Knoten, DefaultWeightedEdge> holz;
     AbstractGraph<Knoten, DefaultWeightedEdge> euBig;
    private AlgoHierholzer bigholz;
    private AlgoFleury bigfleury;

    private void init(){
			
		holz = (AbstractGraph<Knoten, DefaultWeightedEdge>) ReadFile.getInstance().getGraph("C:\\Users\\Administrator\\workspace\\Develop\\Studium\\Gka\\a2_P04_Gersdorf_Wekwert\\wiki_Holz.gka");

        euBig = (AbstractGraph<Knoten, DefaultWeightedEdge>) ReadFile.getInstance().getGraph("C:\\Users\\Administrator\\workspace\\Develop\\Studium\\Gka\\a2_P04_Gersdorf_Wekwert\\EuBig.gka");

        hier = new AlgoHierholzer(holz);
		fleury= new AlgoFleury(holz);

        bigholz = new AlgoHierholzer(euBig);
        bigfleury   = new AlgoFleury(euBig);
	}
	
	@Test
	public void holzTest(){
		init();
		assertEquals(holz.edgeSet().size()+1, hier.getWay().size());
		assertEquals(holz.edgeSet().size(), hier.getTheShortestWay().size());

        assertEquals(euBig.edgeSet().size()+1, bigholz.getWay().size());
        assertEquals(euBig.edgeSet().size(), bigholz.getTheShortestWay().size());



        for(DefaultWeightedEdge edge : holz.edgeSet()){
			if(!hier.getTheShortestWay().contains(edge)){
				System.err.println("fehler");
			}
			
		}
		
	}
	
	@Test
	public void fleuryTest(){
		init();
		assertEquals(holz.edgeSet().size()+1, fleury.getWay().size());
		assertEquals(holz.edgeSet().size(), fleury.getTheShortestWay().size());
		for(DefaultWeightedEdge edge : holz.edgeSet()){
			if(!fleury.getTheShortestWay().contains(edge)){
				System.err.println("fehler");
			}
			
		}

        assertEquals(euBig.edgeSet().size()+1, bigfleury.getWay().size());
        assertEquals(euBig.edgeSet().size(), bigfleury.getTheShortestWay().size());
        for(DefaultWeightedEdge edge : euBig.edgeSet()){
            if(!bigfleury.getTheShortestWay().contains(edge)){
                System.err.println("fehler");
            }

        }



    }

}
